import { defineConfig } from 'umi';

import defaultSettings from './defaultSettings';
import proxy from './proxy';

const { REACT_APP_ENV } = process.env;

const path = require('path');
export default defineConfig({
  history: {
    type: 'hash', // 为了解决在非根目录下部署问题，采用hash路由：#/xxx的形式
  },
  // base: process.env.NODE_ENV === 'production' ? './' : '/', 这个加了之后，会在路由上多出一个  './' 如：/#/./welcome
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/', // nginx非根目录下部署
  hash: true, // 是否开启 hash 文件后缀
  antd: {},
  dva: {
    hmr: true,
  },
  layout: {
    locale: true,
    siderWidth: 208,
    ...defaultSettings,
  },
  locale: {
    default: 'zh-CN',
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@ant-design/pro-layout/es/PageLoading',
  },
  targets: {
    ie: 11,
  },
  theme: {
    'primary-color': defaultSettings.primaryColor,
  },
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
  nodeModulesTransform: { type: 'none' },
  exportStatic: {},
  // mfsu: {},
  webpack5: {},
  alias: {
    '~': path.resolve(__dirname, '../'),
  },
});
